<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        th,td{
            width: 200px;
            border: 1px solid black;
        }
        tbody tr{
            background-image: linear-gradient(to right,skyblue,green);
        }
        tbody tr:hover{
            background-image: linear-gradient(to right,green,yellow);
        }
        thead tr{
            background-image: linear-gradient(to top,red,orange);
        }
    </style>
</head>
<body>
    <table>
        <thead>
            <tr>
                <th>姓名</th>
                <th>工会</th>
                <th>等级</th>
            </tr>
        </thead>
        <tbody>
           
        </tbody>
    </table>
</body>
</html>
<script>
    var arr=[
        {
           'xm':"路明非",
           'gh':'狮心会',
           'dj':'S' 
        },
        {
           'xm':"路明泽",
           'gh':'未知',
           'dj':'未知' 
        },
        {
           'xm':"楚子航",
           'gh':'学生会',
           'dj':'S' 
        },
    ]
    var tb=document.querySelector("tbody")
    for(i=0;i<arr.length;i++){
        //1、创建
        var tr=document.createElement("tr")
        //2、赋值
        tr.innerHTML=`
                <td>${arr[i]['xm']}</td>
                <td>${arr[i]['gh']}</td>
                <td>${arr[i]['dj']}</td>
        `;
        //3、添加
        tb.appendChild(tr)
    }
</script>